package com.zzptc.sky.baidudemo.fragments;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.Toast;

import com.zzptc.sky.baidudemo.R;
import com.zzptc.sky.baidudemo.adapter.SOSForSelectShowContactsAdapter;
import com.zzptc.sky.baidudemo.base.BaseFragmentsForSOS;
import com.zzptc.sky.baidudemo.vo.ContactsInfo;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/6/7 007 .
 */

public class SOSForSelectContactsFragment2  extends BaseFragmentsForSOS{

    private RecyclerView rv_select2;
    private List<ContactsInfo> contactslist = new ArrayList<ContactsInfo>();
    private SOSForSelectShowContactsAdapter adapter;

    @Override
    public int getFragmentXml() {
        return R.layout.fragment_sos_selectcontacts2;
    }

    @Override
    public void initView() {
        rv_select2 = (RecyclerView) getThisView().findViewById(R.id.rv_select2);
    }

    @Override
    public void initData() {
        rv_select2.setLayoutManager(new LinearLayoutManager(getActivity()));
        if (contactslist == null){
            Toast.makeText(getActivity(), "空", Toast.LENGTH_SHORT).show();
            return;
        }
        adapter = new SOSForSelectShowContactsAdapter(contactslist);
        rv_select2.setAdapter(adapter);
    }

    public void getContactsList(List<ContactsInfo> list){
        contactslist.clear();
        contactslist.addAll(list);
        if (adapter != null){
            adapter.notifyDataSetChanged();
        }
    }
}
